﻿using System;
using System.Windows.Forms;

namespace LockScreen
{
    public partial class MainHideForm : Form
    {
        public MainHideForm()
        {
            InitializeComponent();
        }

        private void MainHideForm_Load(object sender, EventArgs e)
        {
            this.TransparencyKey = this.BackColor;
            InitMultipleScreen();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (!IsPause)
            {
                switch (COUNT)
                {
                    case 5:
                        MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._5);
                        break;
                    case 4:
                        MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._4);
                        break;
                    case 3:
                        MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._3);
                        break;
                    case 2:
                        MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._2);
                        break;
                    case 1:
                        MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._1);
                        break;
                    case 0:
                        CoreHelper.DoLock(this.Handle);
                        break;
                    default:
                        COUNT = 5;
                        break;
                }
                --COUNT;
            }
        }

        private void InitMultipleScreen()
        {
            Screen[] ses = Screen.AllScreens;
            Int32 count = ses.Length;
            foreach (Screen screen in ses)
            {
                Int32 x = screen.Bounds.X;
                Int32 y = screen.Bounds.Y;
                Int32 width = screen.Bounds.Width;
                Int32 height = screen.Bounds.Height;
                MultipleScreenManager.GetInstance().AddScreen(x, y, width, height);
            }
            MultipleScreenManager.GetInstance().SetPicture(Properties.Resources._6);
        }

        private static Int32 COUNT = 5;
        public static Boolean IsPause = false;
    }

}
